package com.cy.sys.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.cy.sys.log.service.SysMenusService;
import com.cy.sys.pojo.SysmenuId;
import com.cy.sys.shiro.shirogetUtils;

/**
 * 	主体控制层
 * @author Administrator
 *	控制所有的view显示层
 */
@Controller
@RequestMapping("/")
public class SysController {
	@Autowired
	private SysMenusService SysMenusService;
	
	@RequestMapping("dosysUI")
	public String dosysUI(Model model) {
		String name = shirogetUtils.getusername();
		model.addAttribute("name", name);
		List<SysmenuId> userMenus = SysMenusService.findMenusByIds(shirogetUtils.sysuserna().getId());
		model.addAttribute("userMenus", userMenus);
		return "starter";
	}
	
	@RequestMapping("doLogout")
	public String doLogout() {
		return "login";
	}
	
	
	@RequestMapping("dosysLogUI")
	public String dosysLogUI() {
		return "sys/log_list";
	}
	
	
	@RequestMapping("dosysPageUI")
	public String dosysPageUI() {
		return "common/page";
	}
	
	@RequestMapping("doPageUI")
	public String doPageUI() {
		return "common/page";
	}
	
	@RequestMapping("doLoginUI")
	public String doLoginUI() {
		return "login";
	}
	
//	@RequestMapping("dosysmenusUi")
//	public String dosysmenusUi() {
//		return "sys/menu_list";
//	}
	
	//工性的rest风格
	@RequestMapping("{model}/{modelUI}")
	public String dosysmenusrest(@PathVariable String modelUI) {
		//System.out.println(modelUI+"======");
		System.out.println("sys/"+modelUI);
		return "sys/"+modelUI;
	}
	
}
